package com.ljc.im.server;

import lombok.extern.slf4j.Slf4j;
import org.tio.server.ServerGroupContext;
import org.tio.websocket.server.WsServerStarter;
import org.tio.websocket.server.handler.IWsMsgHandler;

import java.io.IOException;

/**
 * @Author: ljc
 * @Date:Created in 9:06 2022/2/25
 */
@Slf4j
public class ImServerStart {
   private  WsServerStarter starter;
    public ImServerStart(int  port) throws IOException {
        IWsMsgHandler handler = new ImWsMsgHandler();
         starter=new WsServerStarter(port,handler);

        //心跳
        ServerGroupContext serverGroupContext = starter.getServerGroupContext();
        serverGroupContext.setHeartbeatTimeout(5000);
    }
    public void start() throws IOException {
        starter.start();
        log.info("tio server start*********");
    }
}
